from crawler_core.constant.constants import Constants
from login_server.impl.login_51job import LoginJob51
from login_server.impl.login_boss import LoginBoss
from login_server.impl.login_dajie import LoginDajie
from login_server.impl.login_hunter import LoginHunter
from login_server.impl.login_lagou import LoginLagou
from login_server.impl.login_zhaopin import LoginZhaopin


class LoginProxy(object):
    def __init__(self):
        pass

    def login(self, context):

        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_LAGOU:
            info = LoginLagou()
        elif context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_51JOB:
            info = LoginJob51()
        elif context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_ZHAOPIN:
            info = LoginZhaopin()
        elif context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_BOSS:
            info = LoginBoss()
        elif context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_DAJIE:
            info = LoginDajie()
        elif context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_HUNTER:
            info = LoginHunter()

        return info.login(context)

    def loginLagou(self, context):
        info = LoginLagou()
        return info.login(context)

    def login51job(self, context):
        info = LoginJob51()
        return info.login(context)
